<template>
    <div v-resize="handleResize" class="ivu-mt">
        <div v-if="!show">
            <base-info ref="baseInfo" :localList="formItem" :baseData="baseData" @configParam="configParam"
                @topArray="topArray" />
            <Card dis-hover>
                <!--      查询条件      -->
                <Form ref="form" :model="ruleForm" :label-width="100" label-position="right">
                    <Row :gutter="12" type="flex">
                        <Col v-bind="grid" class="ivu-mb-16">
                        <DatePicker :options="options[optionsKey]" @on-change="searchTable" type="daterange"
                            v-width="'100%'" v-model="ruleForm.time" placeholder="日期选择" />
                        </Col>
                        <Col span="6">
                        <Input @on-enter="searchTable" v-model="ruleForm.keywords" placeholder="请输入患者姓名/手机号/诊疗号" />
                        </Col>
                        <Col v-bind="grid">
                        <Select @on-change="searchTable" v-model="ruleForm.outpatient_type_id" placeholder="就诊类型"
                            clearable>
                            <Option v-for="item in typeList" :key="item.id" :value="item.id">{{ item.name }}</Option>
                        </Select>
                        </Col>
                        <Col span="10">
                        <FormItem label="标签">
                            <Select @on-change="searchTable" v-model="ruleForm.tags_ids" multiple filterable
                                :max-tag-count="3">
                                <OptionGroup v-for="(item, index) in tagList" :key="'item' + index" :label="item.name">
                                    <Option v-for="option in item.children" :value="option.id"
                                        :key="option.id + option.name">{{ option.name }}</Option>
                                </OptionGroup>
                            </Select>
                        </FormItem>
                        </Col>
                    </Row>
                </Form>
                <!--      我的报表、已回访、过期未回访     -->
                <Table size="small" ref="myReport" :columns="columns" :data="dataList" :loading="loading"
                    @on-sort-change="handleChangeSort">
                    <template slot-scope="{ row }" slot="info">
                        <a href="javaScript:;" @click="handleDetailPatient(row)">{{ row.name }} , {{ row.age }} ,
                            {{ row.gender_str }}</a>
                    </template>
                    <template slot-scope="{ row }" slot="belong_member_name">
                        <span v-if="row.belong_member_name">
                            <span v-if="row.belong_member_name.length < 4">
                                {{row.belong_member_name}}
                            </span>
                            <Poptip v-else word-wrap transfer trigger="hover" placement="bottom" width="200"
                                :content="row.belong_member_name">
                                {{row.belong_member_name.substring(0, 4)}}…
                            </Poptip>
                        </span>
                        <span v-else>无</span>
                    </template>
                    <template slot-scope="{ row }" slot="patient_card_id">
                        <span v-if="row.patient_card_id">
                            <span v-if="row.patient_card_id.length < 15">
                                {{row.patient_card_id}}
                            </span>
                            <Poptip v-else word-wrap transfer trigger="hover" placement="bottom" width="200"
                                :content="row.patient_card_id">
                                {{row.patient_card_id.substring(0, 15)}}…
                            </Poptip>
                        </span>
                        <span v-else>无</span>
                    </template>
                    <template slot-scope="{row}" slot="outpatient_name">
                        <Tag class="blueStatus" v-if="row.outpatient_name" color="blue">{{ row.outpatient_name }}</Tag>
                    </template>
                    <template slot-scope="{ row }" slot="patient_tags_name_arr">
                        <Poptip word-wrap trigger="hover" placement="right" width="400">
                            <Tag v-for="(item, index) in row.patient_tags_name_arr" :key="index" v-if="index < 3">
                                {{ item }}</Tag>
                            <div slot="content">
                                <Tag v-for="(item, index) in row.patient_tags_name_arr" :key="index">{{ item }}</Tag>
                            </div>
                        </Poptip>
                    </template>
                    <template slot-scope="{row}" slot="source_name">
                        <Badge status="success" :text="row.source_name" />
                    </template>
                    <template slot-scope="{ row }" slot="remark">
                        <span v-if="row.remark">
                            <span v-if="row.remark.length < 12">
                                {{row.remark}}
                            </span>
                            <Poptip v-else word-wrap transfer trigger="hover" placement="bottom" width="200"
                                :content="row.remark">
                                {{row.remark.substring(0, 11)}}…
                            </Poptip>
                        </span>
                        <span v-else>无</span>
                    </template>
                    <template slot-scope="{ row, index }" slot="action">
                        <a v-if="tableStatus === 'myReport'" @click="handleOpenDrawer(row.id)">编辑</a>
                        <Divider v-if="tableStatus === 'myReport'" type="vertical" />
                        <a @click="handleOpenSubmit(row)">回访</a>
                    </template>
                </Table>
                <div class="ivu-mt ivu-text-center">
                    <Page :total="total" :current.sync="page" show-total show-elevator :page-size="pageSize"
                        @on-change="changePage" :page-size-opts="pageOpts" show-sizer transfer
                        @on-page-size-change="changePageSize" />
                </div>
            </Card>
            <table-model ref="editModel" />
            <edit-patient ref="editPatient" @ok="onLoad" />
        </div>
        <Card v-if="show" :bordered="false" dis-hover class="ivu-mt">
            <Form ref="form" :model="ruleForm">
                <Row :gutter="12" type="flex">
                    <Col span="4">
                    <RadioGroup v-model="phone" type="button" @on-change="swicths">
                        <Radio label="1">今天</Radio>
                        <Radio label="2">昨天</Radio>
                        <Radio label="3">周</Radio>
                        <Radio label="4">月</Radio>
                    </RadioGroup>
                    </Col>
                    <Col span="4" class="ivu-mb-16">
                    <DatePicker :clearable="false" :options="options3" @on-change="searchTables" type="daterange"
                        v-width="'100%'" v-model="time" placeholder="日期选择" />
                    </Col>
                </Row>
            </Form>
            <Table :columns="columns1" :data="arr"></Table>
        </Card>
        <Drawer :closable="false" v-model="showTetailDrawer" width="1000" class="edtailDrawers"  >
            <detailDrawer :editType="edit_type" v-if="patientId&&showTetailDrawer" :patientId="patientId"></detailDrawer>
        </Drawer>
    </div>
</template>
<script>
    import tableModel from '@/components/visitModel/table-model';
    import EditPatient from '../../patient/patient-list/modules/editPatient'
    import baseInfo from './base-info';
    import visitChart from './visit-chart';
    import patientChart from './patient-chart';
    import { formatWithYear, getThisDate, getFirstDayOfWeek, getFirstDayOnWeek, getFirstMonthOnWeek } from '@/utils/datetime';
    import tableCol from './columns'
    import dayjs from 'dayjs'
    import detailDrawer from '../../patient/patient-detail/index.vue'
    import mixins from '@/utils/mixins'
    import {
        GetReportCallback, GetReportPatient, GetMyReport,
        GetAddMyReport, GetArriveMyReport, GetOrderMyReport,
        GetUnarriveMyReport, GetCallbackedMyReport, GetUncallbackMyReport, GetNurseReport
    } from '@api/dashboard'

    export default {
        name: 'dashboard-console',
        components: { detailDrawer, baseInfo, visitChart, patientChart, tableModel, EditPatient },
        mixins: [mixins],
        data () {
            return {
                patientId: null,
                edit_type: 3,
                showTetailDrawer: false,
                show: true,
                phone: '1',
                time: [],
                dataList: [],
                loading: false,
                visitType: 'day', // day, month, year
                visitDate: [(new Date()), (new Date())],
                patientDate: [(new Date()), (new Date())],
                formItem: {
                    add_type: '1',	// 新增
                    arrive_type: '1',	// 已到
                    order_arrive_type: '1',	// 预到
                    unarrive_type: '2', // 过期未到
                    callback_type: '1', // 已回访次数
                    uncallback_type: '2' // 过期未回访
                },
                tableStatus: 'myReport',
                sortData: {
                    sort_last_revisiting_type: 0,
                    sort_next_revisiting_type: 0,
                    sort_last_callback_type: 0,
                    sort_next_callback_type: 0,
                    sort_revisiting_type: 0,
                    sort_callback_type: 0,
                    sort_missed_type: 0
                },
                ruleForm: {
                    time: [],
                    tags_ids: [],
                    outpatient_type_id: '',
                    keywords: ''
                },
                options: {
                    ruleNow: {
                        disabledDate (pick) {
                            const curDate = new Date()
                            let reVal = 0
                            if (pick > curDate) {
                                reVal = 1
                            }
                            return reVal
                        }
                    },
                    ruleOld: {
                        disabledDate (pick) {
                            const curDate = dayjs().subtract(1, 'day')
                            let reVal = 0
                            if (pick < curDate) {
                                reVal = 1
                            }
                            return reVal
                        }
                    }
                },
                optionsKey: 'ruleOld',
                topKey: 'order_arrive_type',
                typeList: [],
                tagList: [],
                baseData: {},
                columns: tableCol.myReport,
                myReport: tableCol.myReport, // 我的报表
                already: tableCol.already, // 已回访
                overdue: tableCol.overdue, // 过期未回访
                optionList: {},
                clickStatus: false,
                columns1: [
                    {
                        title: '项目',
                        key: 'project',
                        minWidth: 130,
                        fixed: 'left'
                    },
                    {
                        title: '',
                        key: 'total',
                        minWidth: 130,
                        fixed: 'right'
                    }
                ],
                nowDayTime: '',
                nowWeekStart: '',
                nowWeekEnd: '',
                nowMonthStart: '',
                nowMonthEnd: '',
                yesterdayT: '',
                num: '',
                yestweek: '',
                yesterdays: '',
                arr: [],
                member: {},
                options3: {
                    disabledDate (date) {
                        return date && date.valueOf() > Date.now();
                    }
                }
            }
        },
        created () {
            // this.getLoad();
            // this.getLocalMyReport()
            let formItem = localStorage.getItem('formItem')
            this.formItem = JSON.parse(formItem)
            let is_nurse = localStorage.getItem('is_nurse')
            if (is_nurse === '0') {
                this.show = false
            } else if (is_nurse === '1') {
                this.show = true
            }
            this.getNowDay()
            this.getNurseReport()
        },
        mounted () {
            this.getSixItem()
        },
        methods: {
            closeDrawer(){
                this.onLoad()
            },
            setColums () {
                let size = 0, key
                for (key in this.member) {
                    if (this.member.hasOwnProperty(key)) size++
                }
                if (size === 1) {
                    this.columns1 = [
                        {
                            title: '项目',
                            key: 'project',
                            minWidth: 130,
                            fixed: 'left'
                        }
                    ]
                } else {
                    this.columns1 = [
                        {
                            title: '项目',
                            key: 'project',
                            minWidth: 130,
                            fixed: 'left'
                        },
                        {
                            title: '合计',
                            key: 'total',
                            minWidth: 130,
                            fixed: 'right'
                        }
                    ]
                }
                let i = {}
                for (i in this.member) {
                    this.columns1.push({
                        title: this.member[i] + '',
                        key: i + ''
                    })
                }
            },
            swicths (e) {
                this.num = e
                if (e === '1') {
                    this.time = [this.nowDayTime, this.nowDayTime]
                    this.getNurseReport()
                } else if (e === '2') {
                    this.time = [this.yesterdayT, this.yesterdayT]
                    this.getNurseReport()
                } else if (e === '3') {
                    this.time = [this.yestweek, this.nowDayTime]
                    this.getNurseReport()
                } else if (e === '4') {
                    this.time = [this.yesterdays, this.nowDayTime]
                    this.getNurseReport()
                }
            },
            searchTables (e) {
                if (!e) return false
                const startTime = e[0] || ''
                const endTime = e[1] || ''
                const nowDay = dayjs(this.nowDayTime).format('YYYY-MM-DD') // 当天
                const nowMonthStart = dayjs(this.yesterdayT).format('YYYY-MM-DD')
                const nowMonthEnd = dayjs(this.yesterdays).format('YYYY-MM-DD')
                const nowWeekStart = dayjs(this.yesterday).format('YYYY-MM-DD')
                const nowWeekEnd = dayjs(this.yestweek).format('YYYY-MM-DD')
                if (startTime === nowDay && endTime === nowDay) {
                    this.phone = '1'
                } else if (startTime === nowMonthStart && endTime === nowMonthStart) {
                    this.phone = '2'
                } else if (startTime === nowWeekEnd && endTime === nowDay) {
                    this.phone = '3'
                } else if (startTime === nowMonthEnd && endTime === nowDay) {
                    this.phone = '4'
                } else {
                    this.phone = ''
                }
                if (e[0] === '' && e[1] === '') {
                } else {
                    this.time = e
                    this.getNurseReport()
                }
            },
            getLocalMyReport () {
                const list = JSON.parse(localStorage.getItem('formItem'))
                if (list) this.formItem = list
                else {
                    this.formItem = {
                        add_type: '1',	// 新增
                        arrive_type: '1',	// 已到
                        order_arrive_type: '1',	// 预到
                        unarrive_type: '2', // 过期未到
                        callback_type: '1', // 已回访次数
                        uncallback_type: '2' // 过期未回访
                    }
                }
            },
            getNowDay () {
                const now = new Date()
                const nowMonth = now.getMonth()
                const nowYear = now.getFullYear()
                this.nowDayTime = now
                const time = (new Date()).getTime() - (24 * 60 * 60 * 1000)
                const times = (new Date()).getTime() + (7 * 24 * 60 * 60 * 1000)
                const etime = (new Date()).getTime() - (29 * 24 * 60 * 60 * 1000)
                const week = (new Date()).getTime() - (6 * 24 * 60 * 60 * 1000)
                this.yesterdayT = new Date(time)
                this.yesterday = new Date(times)
                this.yesterdays = new Date(etime)
                this.yestweek = new Date(week)
                this.nowMonthStart = new Date(nowYear, nowMonth, 1)
                this.nowMonthEnd = getFirstMonthOnWeek(new Date())
                this.nowWeekStart = getFirstDayOfWeek(new Date())
                this.nowWeekEnd = getFirstDayOnWeek(new Date())
                const nowYears = dayjs(this.nowDayTime).format('YYYY-MM-DD')
                this.nowDayTime = nowYears
                this.time = [this.nowDayTime, this.nowDayTime]
            },
            getLoad () {
                this.getReportCallback();
                this.getReportPatient();
            },
            getReportCallback () {
                const params = {
                    start_time: this.formDate(this.visitDate[0]),
                    end_time: this.formDate(this.visitDate[1])
                }
                GetReportCallback(params).then((res) => {
                    this.$refs.visitChart.handleGetData(res, this.visitType);
                }).catch(() => { })
            },
            getNurseReport () {
                if (this.time[0] !== undefined && this.time[0] !== '') {
                    this.time = [dayjs(this.time[0]).format('YYYY-MM-DD'), dayjs(this.time[1]).format('YYYY-MM-DD')]
                } else {
                    this.time = ['', '']
                }
                this.member = {}
                const config = {
                    start_date: this.time[0],
                    end_date: this.time[1]
                }
                GetNurseReport(config).then(res => {
                    this.arr = res.list
                    this.member = res.member
                    this.setColums()
                })
            },
            getReportPatient () {
                const params = {
                    start_time: this.formDate(this.patientDate[0]),
                    end_time: this.formDate(this.patientDate[1])
                }
                GetReportPatient(params).then((res) => {
                    this.$refs.patientChart.handleGetData(res);
                }).catch(() => { })
            },
            handleChangeVisitType (val) {
                if (val) {
                    this.visitDate = getThisDate(val);
                }
                this.getReportCallback()
            },
            // 监听页面宽度变化，刷新表格
            handleResize () {
                // this.$refs.visitChart.handleResize();
                // this.$refs.patientChart.handleResize();
            },
            formDate (date) {
                return formatWithYear(date, '-')
            },
            getConfig () {
                return {
                    page: this.page,
                    pageSize: this.pageSize,
                    start_time: this.ruleForm.time[0] !== '' ? dayjs(this.ruleForm.time[0]).format('YYYY-MM-DD') : '',
                    end_time: this.ruleForm.time[1] !== '' ? dayjs(this.ruleForm.time[1]).format('YYYY-MM-DD') : '',
                    sort_last_revisiting_type: this.sortData.sort_last_revisiting_type,
                    sort_next_revisiting_type: this.sortData.sort_next_revisiting_type,
                    sort_last_callback_type: this.sortData.sort_last_callback_type,
                    sort_next_callback_type: this.sortData.sort_next_callback_type,
                    sort_missed_type: this.sortData.sort_missed_type,
                    sort_callback_type: this.sortData.sort_callback_type,
                    sort_revisiting_type: this.sortData.sort_revisiting_type
                }
            },
            // 重置筛选条件
            resetOption () {
                this.ruleForm.tags_ids = []
                this.ruleForm.outpatient_type_id = ''
                this.ruleForm.keywords = ''
            },
            // 获取表格数据
            onLoad () {
                if (this.clickStatus) return false
                this.clickStatus = true
                const option = {
                    keywords: this.ruleForm.keywords,
                    outpatient_type_id: this.ruleForm.outpatient_type_id,
                    tags_ids: this.ruleForm.tags_ids ? this.ruleForm.tags_ids.join(',') : '',
                    ...this.sortData
                }
                const config = Object.assign(option, this.getConfig())
                const key = this.topKey
                this.dataList = []
                if (key === 'add_type') { // 新增
                    GetAddMyReport(config).then(res => {
                        this.dataList = res.list
                        this.total = res.total
                        this.getClinic(res)
                    }).finally(() => { this.clickStatus = false })
                } else if (key === 'arrive_type') { // 已到
                    GetArriveMyReport(config).then(res => {
                        this.dataList = res.list
                        this.total = res.total
                        this.getClinic(res)
                    }).finally(() => { this.clickStatus = false })
                } else if (key === 'order_arrive_type') { // 预到
                    GetOrderMyReport(config).then(res => {
                        this.dataList = res.list
                        this.total = res.total
                        this.getClinic(res)
                    }).finally(() => { this.clickStatus = false })
                } else if (key === 'unarrive_type') { // 过期未到
                    GetUnarriveMyReport(config).then(res => {
                        this.dataList = res.list
                        this.total = res.total
                        this.getClinic(res)
                    }).finally(() => { this.clickStatus = false })
                } else if (key === 'callback_type') { // 已回访次数
                    GetCallbackedMyReport(config).then(res => {
                        this.dataList = res.list
                        this.total = res.total
                        this.getClinic(res)
                    }).finally(() => { this.clickStatus = false })
                } else if (key === 'uncallback_type') { // 过期未回访
                    GetUncallbackMyReport(config).then(res => {
                        this.dataList = res.list
                        this.total = res.total
                        this.getClinic(res)
                    }).finally(() => { this.clickStatus = false })
                }
            },
            // 监听自定义模态框
            configParam (data) {
                this.formItem = data.data
                this.page = 1
                this.pageSize = 10
                this.resetOption()
                this.getSixItem()
            },
            // 监听6个按钮
            topArray (key) {
                this.topKey = key
                this.page = 1
                this.pageSize = 10
                this.getOption()
                this.resetOption()
                // 切换日期规则
                if (key === 'order_arrive_type') { // 预到
                    this.optionsKey = 'ruleOld'
                } else {
                    this.optionsKey = 'ruleNow'
                }
                // 切换表格内容
                if (key === 'uncallback_type') { // 过期未回访
                    this.tableStatus = 'overdue'
                    this.columns = this.overdue
                } else if (key === 'callback_type') { // 已回访
                    this.tableStatus = 'already'
                    this.columns = this.already
                } else { // 我的报表
                    this.columns = this.myReport
                }
                this.onLoad()
            },
            // 切换日期输入框内容
            changeTime (key) {
                const num = this.formItem[key]
                // 1:今日、 2:昨日 || 明日、 3:周、 4:月
                switch (num) {
                case '1':
                    this.ruleForm.time = [new Date(), new Date()]
                    break
                case '2':
                    if (key === 'order_arrive_type' || key === 'callback_type') { // 明日
                        this.ruleForm.time = [dayjs().add(1, 'day'), dayjs().add(1, 'day')]
                    } else this.ruleForm.time = [dayjs().subtract(1, 'day'), dayjs().subtract(1, 'day')]
                    break
                case '3':
                    if (key === 'order_arrive_type') this.ruleForm.time = [new Date(), dayjs().add(6, 'day')]
                    else this.ruleForm.time = [dayjs().subtract(6, 'day'), new Date()]
                    break
                case '4':
                    if (key === 'order_arrive_type') this.ruleForm.time = [new Date(), dayjs().add(29, 'day')]
                    else this.ruleForm.time = [dayjs().subtract(29, 'day'), new Date()]
                    break
                default:
                    this.ruleForm.time = [new Date(), new Date()]
                    break
                }
                this.page = 1
                this.pageSize = 10
                this.onLoad()
            },
            // 表格操作按钮-回访
            handleOpenSubmit (row) {
                this.$refs.editModel.handleShow(row, this.typeList, this.tagList, 3)
            },
            // 表格操作按钮-编辑
            handleOpenDrawer (row) {
                this.$refs.editPatient.handleOpenDrawer(row, 3)
            },
            // 表格排序事件
            handleChangeSort (column) {
                this.sortData.sort_last_revisiting_type = 0
                this.sortData.sort_next_revisiting_type = 0
                this.sortData.sort_last_callback_type = 0
                this.sortData.sort_next_callback_type = 0
                this.sortData.sort_missed_type = 0
                this.sortData.sort_callback_type = 0
                this.sortData.sort_revisiting_type = 0
                switch (column.key) {
                case 'last_revisiting_time_str': // 上次到诊
                    column.order === 'asc' ? this.sortData.sort_last_revisiting_type = 1 : column.order === 'normal' ? this.sortData.sort_last_revisiting_type = 0 : this.sortData.sort_last_revisiting_type = 2
                    break;
                case 'next_revisiting_time_str': // 下次复诊
                    column.order === 'asc' ? this.sortData.sort_next_revisiting_type = 1 : column.order === 'normal' ? this.sortData.sort_next_revisiting_type = 0 : this.sortData.sort_next_revisiting_type = 2
                    break;
                case 'last_callback_time_str': // 上次回访时间
                    column.order === 'asc' ? this.sortData.sort_last_callback_type = 1 : column.order === 'normal' ? this.sortData.sort_last_callback_type = 0 : this.sortData.sort_last_callback_type = 2
                    break;
                case 'next_callback_time_str': // 下次回访时间
                    column.order === 'asc' ? this.sortData.sort_next_callback_type = 1 : column.order === 'normal' ? this.sortData.sort_next_callback_type = 0 : this.sortData.sort_next_callback_type = 2
                    break;
                case 'revisiting_count': // 复诊次数
                    column.order === 'asc' ? this.sortData.sort_revisiting_type = 1 : column.order === 'normal' ? this.sortData.sort_revisiting_type = 0 : this.sortData.sort_revisiting_type = 2
                    break;
                case 'missed_days': // 未到诊天数
                    column.order === 'asc' ? this.sortData.sort_missed_type = 1 : column.order === 'normal' ? this.sortData.sort_missed_type = 0 : this.sortData.sort_missed_type = 2
                    break;
                case 'callback_count': // 回访次数
                    column.order === 'asc' ? this.sortData.sort_callback_type = 1 : column.order === 'normal' ? this.sortData.sort_callback_type = 0 : this.sortData.sort_callback_type = 2
                    break;
                }
                if (column.key === 'diff_day') {
                    if (column.order === 'asc') {
                        var compare = function (obj1, obj2) {
                            var val1 = obj1.diff_day;
                            var val2 = obj2.diff_day;
                            if (val1 < val2) {
                                return -1;
                            } else if (val1 > val2) {
                                return 1;
                            } else {
                                return 0;
                            }
                        }
                        return this.dataList = this.dataList.sort(compare)
                    } else if (column.order === 'desc') {
                        var compare = function (obj1, obj2) {
                            var val1 = obj1.diff_day;
                            var val2 = obj2.diff_day;
                            if (val1 > val2) {
                                return -1;
                            } else if (val1 < val2) {
                                return 1;
                            } else {
                                return 0;
                            }
                        }
                        return this.dataList = this.dataList.sort(compare)
                    } else {

                    }
                }
                this.onLoad()
            },
            // enter模糊搜索
            searchTable () {
                this.page = 1
                this.pageSize = 10
                this.onLoad()
            },
            // 点击个人信息查看详情
            handleDetailPatient (row) {
                this.patientId = row.id
                this.showTetailDrawer = true
                // this.$store.commit('admin/page/setPatientDetail', { patientId: row.id, edit_type: 3 })
                // this.$router.push('/patient/detail')
            },
            // 获取首次渲染数据
            getSixItem () {
                const config = Object.assign({ ...this.formItem }, this.getConfig())
                delete config.start_time
                delete config.end_time
                this.baseData = {}
                this.ruleForm.time = []
                GetMyReport(config).then(res => {
                    this.formItem = {
                        add_type: '1',	// 新增
                        arrive_type: '1',	// 已到
                        order_arrive_type: '1',	// 预到
                        unarrive_type: '2', // 过期未到
                        callback_type: '1', // 已回访次数
                        uncallback_type: '2' // 过期未回访
                    }
                    this.optionList = res.condition
                    this.baseData = res
                    this.getOption()
                    this.getClinic(res)
                    this.onLoad()
                })
            },
            // 获取条件列表
            getOption () {
                const res = this.optionList
                const start = res[this.topKey].start_time || ''
                const end = res[this.topKey].end_time || ''
                this.ruleForm.time = [start ? new Date(start) : '', end ? new Date(end) : '']
            },
            getClinic (res) {
                this.typeList = res.condition.outpatient_type_list || []
                this.tagList = res.condition.tags_list || []
            }
        }
    }
</script>
<style lang="less">
    .dashboard-console-visit {
        .ivu-radio-group-button .ivu-radio-wrapper {
            border: none !important;
            box-shadow: none !important;
            padding: 0 12px;
        }

        .ivu-radio-group-button .ivu-radio-wrapper:before,
        .ivu-radio-group-button .ivu-radio-wrapper:after {
            display: none;
        }
    }

    .ivu-mt-64 {
        margin-top: 64px;
    }

    .blueStatus {
        line-height: 20px;
        background: #e6fffb;
        border-color: #87e8de;
        font-size: 12px;
        color: #13c2c2 !important;
    }
</style>
